//给定一个有 N 个元素的非负序列，求长度大于等于 M 的连续子序列的最大平均值。



#include <iostream>
#include <algorithm>

using namespace std;

#define int long long 

const int N = 1e5 + 10;
int a[N], b[N];

bool check(int* a, int n, int M, int A) {
	for (int i = 1; i <= n; i++) b[i] = a[i] - A; //求大于A的数字
	b[0] = 0;
	for (int i = 1; i <= n; i++) b[i] += b[i - 1]; //前缀和
	int pre = 0;
	for(int i=M;i<=n;i++){
		pre = min(pre, b[i - M]); //记录
		if (b[i] - pre >= 0) return 1; //表示该区间有一个数满足条件
	}
	return 0; 
}

int solve(int* a, int n, int M, int max_num) { //用二分找出最合适的值
	int head = 0, tail = max_num, mid;
	while (head < tail) {
		mid = (head + tail + 1) / 2;
		if (check(a, n, M, mid))head = mid;
		else tail = mid - 1;
	}
	return head;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	int max_num = 0; // 记录最大值
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		x *= 1000;
		a[i] = x;
		max_num = max(x, max_num);
	}

	cout << solve(a, n, m, max_num) << endl;

	return 0;
}